library(dplyr)
library(readr)
library(leaflet)
library(ggplot2)
meteorites <- read_csv(
"Meteorite_Landings.csv",
col_types = cols(year = col_character())
) %>%
rename (mass = `mass (g)` ) %>%
mutate(
date = as.POSIXct(year,format="%d/%m/%Y %H:%M:%OS"),
recency = 2020 - lubridate::year(date)
)
head(meteorites, 7)
## # A tibble: 7 x 12
## name id nametype recclass mass fall year reclat reclong
## <chr> <dbl> <chr> <chr> <dbl> <chr> <chr> <dbl> <dbl>
## 1 Aach… 1 Valid L5 21 Fell 01/0… 50.8 6.08
## 2 Aarh… 2 Valid H6 720 Fell 01/0… 56.2 10.2
## 3 Abee 6 Valid EH4 107000 Fell 01/0… 54.2 -113
## 4 Acap… 10 Valid Acapulc… 1914 Fell 01/0… 16.9 -99.9
## 5 Achi… 370 Valid L6 780 Fell 01/0… -33.2 -65.0
## 6 Adhi… 379 Valid EH4 4239 Fell 01/0… 32.1 71.8
## 7 Adzh… 390 Valid LL3-6 910 Fell 01/0… 44.8 95.2
## # … with 3 more variables: GeoLocation <chr>, date <dttm>, recency <dbl>
meteorites = meteorites %>%
filter( recency >= 0) %>%
mutate(
log_mass = log10(mass)
)
ggplot(meteorites, aes(x=log_mass)) + geom_histogram(col = "black")
meteorites = meteorites %>%
filter( recency >= 0, recency < 200)
ggplot(meteorites, aes(x=recency)) + geom_histogram(col = "black")
Interactive map of astroid locations
greens <- colorNumeric("Reds", domain = NULL)
leaflet(
data = meteorites,
width = "1400px", height = "1100px",
) %>%
addTiles() %>%
addCircleMarkers(
~reclong, ~reclat,
label = ~name,
radius = ~0.8*log_mass,stroke = TRUE, weight = 2,
fillOpacity = .75,
color = ~greens(recency)
)
## Warning in validateCoords(lng, lat, funcName): Data contains 7201 rows with
## either missing or invalid lat/lon values and will be ignored